package com.example.app;

import com.example.config.SpringConfig3;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class App3 {
    public static void main(String[] args) {
        ApplicationContext applicationContext = new AnnotationConfigApplicationContext(SpringConfig3.class);
//        获取beanDefinitionNames
        String[] beanDefinitionNames = applicationContext.getBeanDefinitionNames();
//        我们发现如果没有给bean一个id spring会自动创建一个
        for (String beanDefinitionName : beanDefinitionNames) {
            System.out.println(beanDefinitionName);
        }
        System.out.println("=============");
        System.out.println(applicationContext.getBean("dog"));
        System.out.println(applicationContext.getBean("dog"));
        System.out.println(applicationContext.getBean("dog"));


    }
}
